<?php
namespace app\admin\controller;

use app\common\controller\AdminBaseController;
use app\common\ext\IDb;
use app\common\ext\IRequest;

class UserCompany extends AdminBaseController{

    /**
     * @功能：用户企业信息
     * @开发者：cxl
     * @return string
     */
    public function user_company_list(){
        //接收参数
        $user_id = IRequest::get('user_id');
        $user_company_id = IRequest::get('user_company_id');
        $company_name = IRequest::get('company_name');
        $law_man = IRequest::get('law_man');
        $manager = IRequest::get('manager');
        $phone = IRequest::get('phone');
        $company_type = IRequest::get('company_type');

        //设置查询条件
        $where = null;
        if(!empty($user_id)) $where['user_id'] = $user_id;
        if(!empty($user_company_id)) $where['user_company_id'] = $user_company_id;
        if(!empty($company_type)) $where['company_type'] = $company_type;
        if(!empty($company_name)) $where['company_name'] = array("like","%{$company_name}%");
        if(!empty($law_man)) $where['law_man'] = array("like","%{$law_man}%");
        if(!empty($manager)) $where['manager'] = array("like","%{$manager}%");
        if(!empty($phone)) $where['phone'] = array("like","%{$phone}%");
        $user_company_list = IDb::getInstance('asset_company')->setDbWhere($where)->setDbOrder("asset_company_id desc")->pag();

        //页面赋值
        $this->assign("user_id",$user_id);
        $this->assign("user_company_id",$user_company_id);
        $this->assign("company_name",$company_name);
        $this->assign("law_man",$law_man);
        $this->assign("manager",$manager);
        $this->assign("phone",$phone);
        $this->assign("company_type",$company_type);
        $this->assign("user_company_list",$user_company_list);

        //渲染模板输出
        return view();
    }

    /**
     * @功能：用户企业信息详情
     * @开发者：cxl
     * @return string
     */
    public function user_company_info(){
        //接收参数
        $user_company_id = IRequest::get('asset_company_id',IRequest::NOT_EMPTY,"用户企业编号不能为空！");

        //设置查询条件
        $where['asset_company_id'] = $user_company_id;
        $user_company_info = IDb::getInstance('asset_company')->setDbWhere($where)->row();

        //设置layout
        $this->layout("layout_empty");

        //页面赋值
        $this->assign("user_company_info",$user_company_info);

        //渲染模板输出
        return view();
    }
}
